home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ULARN.ARJ / ULARN.TAR / ularn / header.h < prev    next >
C/C++ Source or Header  |  1989-10-25  |  14KB  |  462 lines

  1. /*    header.h */
  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4. #include <sys/timeb.h>
  5.  
  6. #ifdef BSD
  7. #    include <sys/time.h>
  8. #    include <sgtty.h>
  9. #else
  10. #    include <sys/times.h>
  11. #    include <termio.h>
  12. #endif
  13.  
  14. #include <fcntl.h>
  15. #include <ctype.h>
  16. #include <varargs.h>
  17. #include <pwd.h>
  18. #include <signal.h>
  19. #include <stdio.h>
  20.  
  21. #define SCORENAME   "Uscore"
  22. #define LOGFNAME    "Ulog"
  23. #define HELPNAME    "Uhelp"
  24. #define LEVELSNAME  "Umaps"
  25. #define FORTSNAME   "Ufortune"
  26.  
  27. #define MAXLEVEL 16 /*    max # levels + 1 in the dungeon    */
  28. #define MAXVLEVEL 5 /*    max # of levels in the temple of the luran (volcano) */
  29.  
  30. #define MAXX 67
  31. #define MAXY 17
  32.  
  33. #define SCORESIZE 25     /* this is the number of people on a scoreboard max */
  34. #define MAXPLEVEL 100     /* maximum player level allowed        */
  35.  
  36. /* 56 monsters, 7 demon lords, 1 demon prince, 1 God of Hellfire*/
  37. #define MAXMONST 57     /* maximum # monsters in the dungeon    */
  38.  
  39. #define SPNUM 39     /* maximum number of spells in existance    */
  40. #define MAXSCROLL 28    /* maximum number of scrolls that are possible    */
  41. #define MAXPOTION 35     /* maximum number of potions that are possible    */
  42. #define TIMELIMIT 40000 /* the maximum number moves before the game is called*/
  43. #define TAXRATE 1/20     /* the tax rate for the LRS */
  44. #define MAXOBJ 93     /* the maximum number of objects   n < MAXOBJ */
  45.  
  46. /*    this is the structure definition of the monster data    */
  47. struct monst
  48. {
  49.     char    *name;
  50.     char    level;
  51.     short    armorclass;
  52.     char    damage;
  53.     char    attack;
  54.     char    defense;
  55.     char    genocided;
  56.     char     intelligence; /* used to choose movement */
  57.     short    gold;
  58.     short    hitpoints;
  59.     unsigned long experience;
  60. };
  61.  
  62. /*    this is the structure definition for the items in the dnd store */
  63. struct _itm
  64. {
  65.     short    price;
  66.     char    **mem;
  67.     char    obj;
  68.     char    arg;
  69.     char    qty;
  70. };
  71.  
  72. /*    this is the structure that holds the entire dungeon specifications    */
  73. struct cel
  74. {
  75.     short    hitp;    /*    monster's hit points    */
  76.     char    mitem;    /*    the monster ID        */
  77.     char    item;    /*    the object's ID        */
  78.     short    iarg;    /*    the object's argument    */
  79.     char    know;    /*    have we been here before*/
  80. };
  81.  
  82. /* this is the structure for maintaining & moving the spheres of annihilation */
  83. struct sphere
  84. {
  85.     struct sphere *p;    /* pointer to next structure */
  86.     char x,y,lev;        /* location of the sphere */
  87.     char dir;        /* direction sphere is going in */
  88.     char lifetime;        /* duration of the sphere */
  89. };
  90.  
  91. /*    defines for the character attribute array    c[]    */
  92. #define STRENGTH 0    /* characters physical strength not due to objects */
  93. #define INTELLIGENCE 1
  94. #define WISDOM 2
  95. #define CONSTITUTION 3
  96. #define DEXTERITY 4
  97. #define CHARISMA 5
  98. #define HPMAX 6
  99. #define HP 7
  100. #define GOLD 8
  101. #define EXPERIENCE 9
  102. #define LEVEL 10
  103. #define REGEN 11
  104. #define WCLASS 12
  105. #define AC 13
  106. #define BANKACCOUNT 14
  107. #define SPELLMAX 15
  108. #define SPELLS 16
  109. #define ENERGY 17
  110. #define ECOUNTER 18
  111. #define MOREDEFENSES 19
  112. #define WEAR 20
  113. #define PROTECTIONTIME 21
  114. #define WIELD 22
  115. #define AMULET 23        /* if have amulet of invisibility */
  116. #define REGENCOUNTER 24
  117. #define MOREDAM 25
  118. #define DEXCOUNT 26
  119. #define STRCOUNT 27
  120. #define BLINDCOUNT 28        /* if blind */
  121. #define CAVELEVEL 29
  122. #define CONFUSE 30        /* if confused */
  123. #define ALTPRO 31
  124. #define HERO 32            /* if hero  */
  125. #define CHARMCOUNT 33
  126. #define INVISIBILITY 34        /* if invisible */
  127. #define CANCELLATION 35        /* if cancel cast */
  128. #define HASTESELF 36        /* if hasted */
  129. #define EYEOFLARN 37        /* if have eye */
  130. #define AGGRAVATE 38
  131. #define GLOBE 39
  132. #define TELEFLAG 40        /* if been teleported */
  133. #define SLAYING 41        /* if have orb of dragon slaying */
  134. #define NEGATESPIRIT 42        /* if negate spirit */
  135. #define SCAREMONST 43        /* if scare cast */
  136. #define AWARENESS 44        /* if awareness cast */
  137. #define HOLDMONST 45
  138. #define TIMESTOP 46
  139. #define HASTEMONST 47
  140. #define CUBEofUNDEAD 48        /* if have cube */
  141. #define GIANTSTR 49        /* if giant strength */
  142. #define FIRERESISTANCE 50
  143. #define BESSMANN 51        /* flag for hammer */
  144. #define NOTHEFT 52
  145. #define HARDGAME 53
  146. #define BYTESIN 54        /* used for checkpointing in tok.c */
  147.  
  148.         /* 55 to 59 are open */
  149.  
  150.  
  151.  
  152. #define LANCEDEATH 60        /* if have LoD */
  153. #define SPIRITPRO 61
  154. #define UNDEADPRO 62
  155. #define SHIELD 63
  156. #define STEALTH 64
  157. #define ITCHING 65
  158. #define LAUGHING 66        /* not implemented */
  159. #define DRAINSTRENGTH 67
  160. #define CLUMSINESS 68
  161. #define INFEEBLEMENT 69
  162. #define HALFDAM 70
  163. #define SEEINVISIBLE 71
  164. #define FILLROOM 72
  165.     /* 73 is open */
  166. #define SPHCAST 74    /* nz if an active sphere of annihilation */
  167. #define WTW 75        /* walk through walls */
  168. #define STREXTRA 76    /* character strength due to objects or enchantments */
  169. #define TMP 77        /* misc scratch space */
  170. #define LIFEPROT 78     /* life protection counter */
  171.  
  172.             /* FLAGS : non-zero if object has been made */
  173. #define ORB 79        /* orb - 1 if created, 2 if held */
  174. #define ELVUP 80    /* elevator up */
  175. #define ELVDOWN 81    /* elevator down */
  176. #define HAND 82        /* Hand of Fear */
  177. #define CUBEUNDEAD 83    /* cube of undead control */
  178. #define DRAGSLAY 84    /* orb of dragon slaying */
  179. #define NEGATE 85    /* scarab of negate spirit */
  180. #define URN 86        /* golden urn */
  181. #define LAMP 87        /* brass lamp */
  182. #define TALISMAN 88    /* Talisman of the Sphere */
  183. #define WAND 89        /* wand of wonder */
  184. #define STAFF 90    /* staff of power */
  185. #define DEVICE 91    /* anti-theft */
  186. #define SLASH 92     /* sword of slashing */
  187. #define ELVEN 93    /* elven chain */
  188. #define VORP  94    /* Vorpal */
  189. #define SLAY  95    /* Slayer */
  190. #define PAD   96    /* Dealer McDopes */
  191.  
  192. #define COKED 97    /* timer for being coked out */
  193. /* used up to 97 of 100 */
  194.  
  195. /*    defines for the objects in the game        */
  196. #define OALTAR 1
  197. #define OTHRONE 2
  198. #define OORB 3        /* orb of enlightement - gives expanded awareness
  199.                   as long as held */
  200. #define OPIT 4
  201. #define OSTAIRSUP 5
  202. #define OELEVATORUP 6
  203. #define OFOUNTAIN 7
  204. #define OSTATUE 8
  205. #define OTELEPORTER 9
  206. #define OSCHOOL 10
  207. #define OMIRROR 11
  208. #define ODNDSTORE 12
  209. #define OSTAIRSDOWN 13
  210. #define OELEVATORDOWN 14
  211. #define OBANK2 15
  212. #define OBANK 16
  213. #define ODEADFOUNTAIN 17
  214. #define OMAXGOLD 70
  215. #define OGOLDPILE 18
  216. #define OOPENDOOR 19
  217. #define OCLOSEDDOOR 20
  218. #define OWALL 21
  219. #define OTRAPARROW 66
  220. #define OTRAPARROWIV 67
  221.  
  222. #define OLARNEYE 22
  223.  
  224. #define OPLATE 23
  225. #define OCHAIN 24
  226. #define OLEATHER 25
  227. #define ORING 60
  228. #define OSTUDLEATHER 61
  229. #define OSPLINT 62
  230. #define OPLATEARMOR 63
  231. #define OSSPLATE 64
  232. #define OSHIELD 68
  233.  
  234. #define OSWORDofSLASHING 26    /* impervious to rust, light, strong */
  235. #define OHAMMER 27        /* Bessman's Flailing Hammer */
  236. #define OSWORD 28
  237. #define O2SWORD 29        /* 2 handed sword */
  238. #define OSPEAR 30
  239. #define ODAGGER 31
  240. #define OBATTLEAXE 57
  241. #define OLONGSWORD 58
  242. #define OFLAIL 59
  243. #define OLANCE 65
  244.  
  245. #define ORINGOFEXTRA 32
  246. #define OREGENRING 33
  247. #define OPROTRING 34
  248. #define OENERGYRING 35
  249. #define ODEXRING 36
  250. #define OSTRRING 37
  251. #define OCLEVERRING 38
  252. #define ODAMRING 39
  253.  
  254. #define OBELT 40
  255.  
  256. #define OSCROLL 41
  257. #define OPOTION 42
  258. #define OBOOK 43
  259. #define OCHEST 44
  260.  
  261. #define OAMULET 45
  262. #define OORBOFDRAGON 46
  263. #define OSPIRITSCARAB 47
  264. #define OCUBEofUNDEAD 48
  265. #define ONOTHEFT 49
  266.  
  267. #define ODIAMOND 50
  268. #define ORUBY 51
  269. #define OEMERALD 52
  270. #define OSAPPHIRE 53
  271.  
  272. #define OENTRANCE 54
  273. #define OVOLDOWN 55
  274. #define OVOLUP 56
  275. #define OHOME 69
  276.  
  277. #define OKGOLD 71
  278. #define ODGOLD 72
  279. #define OIVDARTRAP 73
  280. #define ODARTRAP 74
  281. #define OTRAPDOOR 75
  282. #define OIVTRAPDOOR 76
  283. #define OTRADEPOST 77
  284. #define OIVTELETRAP 78
  285. #define ODEADTHRONE 79
  286. #define OANNIHILATION 80        /* sphere of annihilation */
  287. #define OTHRONE2 81
  288. #define OLRS 82                /* Larn Revenue Service */
  289. #define OCOOKIE 83
  290. #define OURN 84            /* golden urn - not implemented */
  291. #define OBRASSLAMP 85    /* brass lamp - genie pops up and offers spell */
  292. #define OHANDofFEAR 86        /* hand of fear - scare monster spell lasts
  293.                    twice as long if have this */
  294. #define OSPHTALISMAN 87        /* talisman of the sphere */
  295. #define OWWAND 88    /* wand of wonder - cant fall in trap doors/pits */
  296. #define OPSTAFF 89        /* staff of power - cancels drain life attack*/
  297.  
  298. #define OVORPAL 90    /* ? - not implemented */
  299. #define OSLAYER 91    /* magical sword - increases intelligence by 10,
  300.                halves damage caused by demons, demon prince 
  301.                and lucifer - strong as lance of death against them*/
  302.  
  303. #define OELVENCHAIN 92        /* elven chain - strong and light, 
  304.                    impervious to rust */
  305. #define OSPEED 93        
  306. #define OACID 94
  307. #define OHASH 95
  308. #define OSHROOMS 96
  309. #define OCOKE 97
  310. #define OPAD 98        /* Dealer McDope's Pad */
  311. /* used up to 98 */
  312.  
  313. /*    defines for the monsters as objects        */
  314.  
  315. #define LEMMING 1 
  316. #define GNOME 2
  317. #define HOBGOBLIN 3
  318. #define JACKAL 4 
  319. #define KOBOLD 5 
  320. #define ORC 6 
  321. #define SNAKE 7
  322. #define CENTIPEDE 8
  323. #define JACULI 9 
  324. #define TROGLODYTE 10 
  325. #define ANT 11 
  326. #define EYE 12 
  327. #define LEPRECHAUN 13
  328. #define NYMPH 14 
  329. #define QUASIT 15 
  330. #define RUSTMONSTER 16 
  331. #define ZOMBIE 17 
  332. #define ASSASSINBUG 18 
  333. #define BUGBEAR 19 
  334. #define HELLHOUND 20 
  335. #define ICELIZARD 21 
  336. #define CENTAUR 22 
  337. #define TROLL 23 
  338. #define YETI 24 
  339. #define WHITEDRAGON 25 
  340. #define ELF 26 
  341. #define CUBE 27 
  342. #define METAMORPH 28 
  343. #define VORTEX 29 
  344. #define ZILLER 30 
  345. #define VIOLETFUNGI 31 
  346. #define WRAITH 32 
  347. #define FORVALAKA 33 
  348. #define LAMANOBE 34 
  349. #define OSEQUIP 35 
  350. #define ROTHE 36 
  351. #define XORN 37 
  352. #define VAMPIRE 38 
  353. #define INVISIBLESTALKER 39 
  354. #define POLTERGEIST 40 
  355. #define DISENCHANTRESS 41 
  356. #define SHAMBLINGMOUND 42 
  357. #define YELLOWMOLD 43
  358. #define UMBERHULK 44
  359. #define GNOMEKING 45
  360. #define MIMIC 46
  361. #define WATERLORD 47
  362. #define BRONZEDRAGON 48
  363. #define GREENDRAGON 49
  364. #define PURPLEWORM 50
  365. #define XVART 51
  366. #define SPIRITNAGA 52
  367. #define SILVERDRAGON 53
  368. #define PLATINUMDRAGON 54
  369. #define GREENURCHIN 55
  370. #define REDDRAGON 56
  371. #define DEMONLORD 57
  372. #define DEMONPRINCE 64
  373. #define LUCIFER 65
  374.  
  375. #define BUFBIG    4096            /* size of the output buffer */
  376. #define MAXIBUF    4096            /* size of the input buffer */
  377. #define LOGNAMESIZE 40            /* max size of the players name */
  378. #define PSNAMESIZE 40            /* max size of the process name */
  379. #define SAVEFILENAMESIZE 128        /* max size of the savefile path */
  380.  
  381. extern char aborted[],beenhere[],boldon,cheat,ckpfile[],ckpflag;
  382. extern char *class[],course[],diagfile[],fortfile[],helpfile[];
  383. extern char *inbuffer,drug[];
  384. extern char item[MAXX][MAXY],iven[],know[MAXX][MAXY],larnlevels[],lastmonst[];
  385. extern char level,*levelname[],logfile[],loginname[],logname[],*lpbuf,*lpend;
  386. extern char *lpnt,moved[MAXX][MAXY],mitem[MAXX][MAXY],monstlevel[];
  387. extern char monstnamelist[],nch[],ndgg[],nlpts[],nomove,nosignal,nowelcome;
  388. extern char nplt[],nsw[],*objectname[], char_class[];
  389. extern char objnamelist[],optsfile[],*potionname[],potprob[];
  390. extern char predostuff,restorflag,savefilename[],scorefile[],scprob[];
  391. extern char screen[MAXX][MAXY],*scrollname[],sex,*spelcode[],*speldescript[];
  392. extern char spelknow[],*spelname[],*spelmes[],spelweird[MAXMONST+8][SPNUM];
  393. extern char splev[],stealth[MAXX][MAXY],wizard;
  394. extern short diroffx[],diroffy[],hitflag,hit2flag,hit3flag,hitp[MAXX][MAXY];
  395. extern short iarg[MAXX][MAXY],ivenarg[],lasthx,lasthy,lastnum,lastpx,lastpy;
  396. extern short nobeep,oldx,oldy,playerx,playery;
  397. extern int dayplay,enable_scroll,srcount,stayflag,yrepcount,userid,lfd,fd;
  398. extern long initialtime,outstanding_taxes,skill[],gtime,c[],cbak[];
  399. extern unsigned long randx;
  400. extern struct cel *cell;
  401. extern struct monst monster[];
  402. extern struct sphere *spheres;
  403. extern struct _itm itm[];
  404.  
  405. char *fortune(),*malloc(),*getenv(),*getlogin(),*lgetw(),*lgetl(),*ctime();
  406. char *tmcapcnv(),*tgetstr(),*tgoto();
  407. long paytaxes(),lgetc(),lrint(),time();
  408. long readnum();
  409.  
  410.     /* macro to create scroll #'s with probability of occurrence */
  411. #define newscroll() (scprob[rund(81)])
  412.     /* macro to return a potion # created with probability of occurrence */
  413. #define newpotion() (potprob[rund(41)])
  414.     /* macro to return the + points on created leather armor */
  415. #define newleather() (nlpts[rund(c[HARDGAME]?10:13)])
  416.     /* macro to return the + points on chain armor */
  417. #define newchain() (nch[rund(10)])
  418.     /* macro to return + points on plate armor */
  419. #define newplate() (nplt[rund(c[HARDGAME]?3:10)])
  420.     /* macro to return + points on new daggers */
  421. #define newdagger() (ndgg[rund(13)])
  422.     /* macro to return + points on new swords */
  423. #define newsword() (nsw[rund(c[HARDGAME]?6:13)])
  424.     /* macro to destroy object at present location */
  425. #define forget() (item[playerx][playery]=know[playerx][playery]=0)
  426.     /* macro to wipe out a monster at a location */
  427. #define disappear(x,y) (mitem[x][y]=know[x][y]=0)
  428.  
  429.     /* defines below are for use in the termcap mode only */
  430. #define ST_START 1
  431. #define ST_END   2
  432. #define BOLD     3
  433. #define END_BOLD 4
  434. #define CLEAR    5
  435. #define CL_LINE  6
  436. #define CL_DOWN 14
  437. #define CURSOR  15
  438.     /* macro to turn on bold display for the terminal */
  439. #define setbold() (*lpnt++ = ST_START)
  440.     /* macro to turn off bold display for the terminal */
  441. #define resetbold() (*lpnt++ = ST_END)
  442.     /* macro to setup the scrolling region for the terminal */
  443. #define setscroll() enable_scroll=1 
  444.     /* macro to clear the scrolling region for the terminal */
  445. #define resetscroll() enable_scroll=0
  446.     /* macro to clear the screen and home the cursor */
  447. #define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50)
  448.     /* macro to clear to end of line */
  449. #define cltoeoln() (*lpnt++ = CL_LINE)
  450.  
  451.     /* macro to output one byte to the output buffer */
  452. #define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ =(ch)))
  453.  
  454.     /* macro to seed the random number generator */
  455. #define srand(x) (randx=x)
  456.     /* macros to generate random numbers   1<=rnd(N)<=N   0<=rund(N)<=N-1 */
  457. #define rnd(x)  ((((randx=randx*1103515245+12345)>>7)%(x))+1)
  458. #define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)))
  459.     /* macros for miscellaneous data conversion */
  460. #define min(x,y) (((x)>(y))?(y):(x))
  461. #define max(x,y) (((x)>(y))?(x):(y))
  462.